package com.the_ring.chapter08;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.the_ring.chapter08.widget.BannerPager;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        BannerPager banner = findViewById(R.id.banner_pager);
        // 获取广告轮播条的布局参数
        ViewGroup.LayoutParams params =  banner.getLayoutParams();
        Display display = getWindowManager().getDefaultDisplay();
        params.height = (int) (display.getWidth() * 250f / 640f);
        banner.setLayoutParams(params);
        banner.setImageViews(getImageList());
        banner.start();
    }


    private List<Integer> getImageList() {
        List<Integer> imageList = new ArrayList<>();
        imageList.add(R.drawable.banner_1);
        imageList.add(R.drawable.banner_2);
        imageList.add(R.drawable.banner_3);
        imageList.add(R.drawable.banner_4);
        imageList.add(R.drawable.banner_5);
        imageList.add(R.drawable.banner_6);
        return imageList;
    }

}